Skip to content

Packs, connectors that are grains, and three blessed wasm tools (#178, #185, #179) - #226

Merged
sathish-mg merged 8 commits into
mainfrom
feat/packs-grain-connectors-blessed-tools
Sep 10, 2026
Merged

sathish-mg merged 8 commits into
mainfrom
feat/packs-grain-connectors-blessed-tools

Conversation

@sathish-mg

@sathish-mg sathish-mg commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #185, closes #178, closes #179.

Three issues that only make sense together: the code an agent runs, how it is
installed, and what nobody should have to write from scratch.

#185 — a trigger can name its connector by content address

A polling connector was a host command, which put the code most likely to be
wrong — cursors, pagination, a provider's quirks — outside the memory: no
bundle carried it, tool provenance could not chase it, and the loop could not
propose a code_revision against it.

A Trigger now carries connector_tool, a reference to a Tool Definition
(not a cas:// address directly — the runtime, limits and capabilities that
decide where the code may reach are Tool fields, and a second place to write
them is a second place for them to disagree). The evaluator reads it through
the same pin_from_definition RunManifest::resolve uses and dispatches
through the same CodeExecutor, so there is one implementation of the pin, the
runtime table and the capability check rather than a second one that drifts on
the surface nobody watches.

The authorization does not travel with the code: --allow-executor on the
evaluating host runs it, and without it the poll refuses with the new
TRG-E012 naming the address to pin, before a broker starts. A host that
pinned nothing does not fall through to --connector-cmd — that would run a
different program than the declaration names.

One fix fell out of the same path: the per-poll broker granted the connector
only the default token, which maps to no caller, so a grain connector's own
capability declaration was invisible to the check that reads it and every blob
read was refused as undeclared.

#178 — areev pack validate | install | export

areev pack validate ./pack                  # opens no memory at all
areev pack install  ./pack --db agent.db    # refuses on a hash mismatch
areev pack export   --db agent.db --ns ops --out ./pack

References are symbolic (blob:<name>, grain:<id>) because an address is
a measurement of bytes; install stores the blob, learns its address, rewrites
the Definition, addresses that, then rewrites the plan binding it.
expected_hash is refused, not warned, with nothing written. Grains are
built and addressed with no store at all, so validate genuinely speaks for
install.

All ten agent examples ship a pack/ exported from their own freshly seeded
memory, and run-smokes.sh gained a pack lane asserting each installs the
plan its language stacks mint. That lane immediately caught a latent bug:
sanctions-screening stamped its Rule E1 evalset with the wall clock, so the
desk's plan hash differed on every seed — invisible until now because the
cross-stack comparison needs two stacks and that desk has one.

#179 — blessed wasm32-areev-io tools

http.call (2,598 bytes), mcp.call, a2a.call ship as committed blobs
with published addresses. http.call makes no policy decision at all — it
hands the request to the broker and the answer back, verbatim both ways — so
the Definition's capabilities and the host's grant are the whole policy: data
in the memory, auditable without reading any code. Two Definitions may name the
same blob with different declarations, which is the shape a fleet wants.

no_std, zero dependencies, a JSON slicer rather than a parser (a caller's
arguments object travels byte for byte). areev-sandbox/tests/blessed_tools.rs
runs the committed bytes under real wasmi against a loopback broker
stand-in, including that the import gate holds in both directions.

Acceptance, and where each clause is proven

Clause Where
#185 · a polling trigger names a wasm32-areev-io connector by content address examples/grain-connector/pack/grains/040-trigger.json; crates/areev-trigger/tests/grain_connector_tests.rs
#185 · an example agent runs with no host connector script examples/grain-connector/run.sh (keyless, offline, in CI)
#178 · the ten example agents install through pack install, smokes pass ten pack/ dirs + the pack lane; REQUIRE="… pack" in CI
#178 · a mismatched expected_hash is refused pack_smoke.rs::a_mismatched_expected_hash_is_refused_with_nothing_written
#178 · pack export round-trips into a fresh memory pack_smoke.rs, both source and bundle formats
#179 · a pack binds http.call with declared hosts examples/blessed-tools/pack/
#179 · a call to an undeclared host is refused by the broker examples/blessed-tools/run.sh step 3 — RUN-E022, journaled
#179 · areev tool provenance chains the blob same script, step 4

Verification

  • cargo test --workspace — 2,123 tests, green (run under cargo llvm-cov)
  • cargo clippy --workspace --all-targets -- -D warnings — clean; same for areev-sandbox and areev-tools
  • coverage 81.8% (was 81.1), every crate at or above its floor
  • repo_stats.py --check, check_versions.py, areev-tools/manifest.py --check — pass
  • all ten agent examples: smoke + improve + pack lane, and both new examples end to end

Two bugs this work surfaced, fixed here

Both are about a piece of governed code and the things that point at it, and
both were found by building the examples above rather than by reading the code.

areev tool provenance reported no runs for a tool a run had just
executed.
docs/run.md said it chains code "to the runs that executed it";
it answered runs_touching: 0. The walk behind it is a provenance walk, and
there is no provenance edge to find — a journal's result grain supersedes its
intent, and neither supersedes the Definition. What connects a run to the code
it ran is §8.4's spec_hash, which nothing read backwards. runs_touching now
follows it for a Tool Definition (Areev::runs_executing), as a bounded scan
skipped entirely unless the target IS a Definition, pinned by a conformance
case on both backends. Affected --tool-cmd tools identically.

cold_grains proposed retiring a Rule E1 gate. An evalset a live
Definition pins is read by the gate at review time, never through recall, so it
aged past the grace window and came back as a retire candidate — naming the one
grain that must not be retired, since removing it removes the gate a
code_revision has to pass. Facts pinned as evalset_hash by a live
Definition are now excluded, and deliberately only those: a general "any hash a
live grain mentions" sweep would swallow the evidence a pending recommendation
cites, and since this analyzer's own findings cite the fact they flag, every
cold finding would suppress itself on the next run.

examples/agents/sanctions-screening drops the config widening it had needed
to work around the second one and asserts the clean result instead, and
examples/blessed-tools/ asserts both runs for the first — the refused one
included, because a request the broker turned down is still a run that touched
that code.

https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8

Three shared blobs ship in the repository with documented content addresses,
plus `mailbox.poll`, the example connector #185 is demonstrated with.

The point is not convenience. A tool gateway that decides *where a request may
go* is code everyone installing it has to trust, and re-audit every time it
changes. `http.call` makes no such decision: it hands the request to the broker
and hands the answer back, verbatim, in both directions. Where it may go, which
method, which credential and which headers are the Definition's `capabilities`
and the host's grant -- data, in the memory, replicated with the tool,
auditable without reading any code. The gateway becomes configuration.

Two Definitions may name the same blob with different declarations, which is
the shape a fleet wants: one address to pin, one blob to review, a per-service
policy the memory states out loud.

`mcp.call` and `a2a.call` add one JSON-RPC envelope and one unwrap over that,
copying the caller's `arguments` BYTE FOR BYTE rather than round-tripping it --
a server that cares about key order sees what the caller wrote. They are
separate blobs rather than one with a mode flag because a pack pins an address
and declares a capability per tool: an MCP server and an agent-to-agent
endpoint are different hosts with different credentials, and one blob doing
both would be one address to grant for both.

`no_std`, no dependencies, `http.call` is 2,598 bytes -- a blessed blob is
reviewed as bytes, so what it carries is part of its security story.
`serde_json` would pull an ecosystem into a module whose job is to move four
strings into a different shape. What replaces it is a JSON *slicer*, not a
parser.

`areev-tools/` is a standalone workspace for the reason `areev-sandbox` and
`areev-js` are, and one more: its crates are cdylibs for
`wasm32-unknown-unknown`, so `cargo test --workspace` has no host to run them
on. An import appears in a built blob only when it is CALLED, which is
load-bearing rather than incidental -- the sandbox refuses an unlinked import
by name before one instruction -- so `manifest.py` asserts each blob's import
set against what its declaration admits, and fails the build rather than
shipping a blob that would be refused at instantiation.

Tested where the engine is: `areev-sandbox/tests/blessed_tools.rs` runs the
COMMITTED bytes under real wasmi against a loopback broker stand-in, asserting
the request each one builds, the answer each one returns, that every published
address is the address of the file beside it, and that the import gate holds in
both directions.

Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8
Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
A polling connector was a host command (`--connector-cmd`), which put the code
most likely to be wrong -- cursors, pagination, a provider's quirks -- outside
the memory: it did not travel in a bundle, `areev tool provenance` could not
chase it, and the loop could not propose a `code_revision` against it. Those
are exactly the failures a gated code revision against recorded fixtures is
built to fix, and they were invisible to a loop that could not see the code.

A Trigger now carries `connector_tool`: a reference to a Tool DEFINITION whose
`executor_uri` is the blob. A Definition and not a `cas://` address directly,
because a blob is bytes -- the runtime, the limits, and above all the
`capabilities` declaration that decides where the code may reach are Tool
fields, and a second place to write them would be a second place for them to
disagree.

The evaluator reads it through the SAME `pin_from_definition` that
`RunManifest::resolve` uses, and dispatches through the same `CodeExecutor`, so
the sandbox argv, the capability registration, the per-call broker handshake
and the cleared environment are one implementation rather than a second one
that drifts -- and the one that would drift is this one, because nobody is
watching a heartbeat.

The authorization deliberately does not travel with the code. `--allow-executor`
on the evaluating host is what runs it; without it the poll refuses with the new
`TRG-E012` naming the address to pin, before a broker is started and before
anything is spent. The same code covers a Definition carrying no
`executor_uri`, a declared runtime with no `--sandbox-cmd`, and a blob-reading
module on an evaluator wired no memory locator. A host that pinned nothing does
NOT fall through to `--connector-cmd`: a fallback would run a different program
than the declaration names, which is the failure with no symptom the pin exists
to refuse.

`connector` (the name) stays required beside it. The run id is derived from
`(trigger, connector, dedup value)`, so revising the code must not renumber the
runs.

One fix falls out of the same path: the per-poll broker granted its connector
only the DEFAULT token, which maps to no caller, so a grain connector's own
capability declaration was invisible to the check that reads it and every blob
read was refused as undeclared. It now also holds a grant under its own name.

Both bindings take the pin on `trigger_run`/`trigger_deliver` off the existing
`ExecutorPin`, so a host grants an address once and it means one thing.
`trigger show` prints the connector and says when it is a grain. The spec-level
record for the field is `docs/oms-1.7-amendments-connector-tool.md`.

Breaking for direct constructors: `areev_trigger::Evaluator` gained a
`connector_code` field.

Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8
Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
@sathish-mg
sathish-mg requested a review from a team as a code owner September 10, 2026 09:26
A pack is an installable agent: a manifest, the grains it seeds, and the code
blobs those grains name. It replaces the installer everyone deploying an agent
was otherwise writing -- blobs into the CAS, each `executor_uri` rewritten to
the address the bytes turned out to have, grains seeded in dependency order,
plan hashes checked -- with one verb, so self-hosters get the same door a
managed deployment does.

Three properties make it more than a script.

References are SYMBOLIC (`blob:<name>`, `grain:<id>`). An address is a
measurement of bytes, not something an author can write down: install stores
the blob, learns its address, rewrites the Definition, addresses *that*, and
rewrites the plan that binds it. Grains are addressed in manifest order and a
forward reference is refused rather than guessed at, which is why `grains` is
an ordered list and not a set. It also means editing a connector's wasm changes
the plan's hash -- the property that makes the next one worth having.

`expected_hash` is REFUSED, not warned, with nothing written. A plan installed
at a different address than the deployment expects has changed what runs, and
everything pointing at the old hash -- triggers above all, which do not follow
heads -- is now pointing elsewhere.

Install is validate plus a destination. Every grain is built and addressed with
NO store at all, since content addressing is a pure function of the serialized
grain, so `pack validate` opens no memory, creates no file, and can run in CI
on a pull request; a refused pack leaves the memory exactly as it found it
(half an agent is worse than none). Export writes either reviewable grain JSON,
refusing to write anything it cannot rebuild to the same address, or a bundle
plus a manifest of what it must contain. Saved queries and templates travel
too, or an installed agent loses the context assembly its triggers name.

The pins it prints are exactly the addresses some Definition names as its
`executor_uri` -- never the data blobs a pack also carries, since asking an
operator to authorize data as executable is asking for the wrong permission.

Every agent under `examples/agents/` now ships a `pack/`, EXPORTED from its own
freshly seeded memory rather than written by hand, because the grains a pack
installs and the grains a seeder writes have to be the same grains and the only
way to keep them the same is to derive one from the other. `run-smokes.sh`
gained a `pack` lane asserting each installs the plan its language stacks mint.

That lane immediately earned itself: `sanctions-screening` stamped its evalset
Fact -- the gate Rule E1 pins on the `screen` tool -- with the wall clock, so
the tool's hash and therefore the desk's plan hash differed on every seed.
Nothing had caught it because the cross-stack comparison needs two stacks and
that desk has one. The seeder now pins `created_at` like every other grain it
writes, and the desk records a wider `cold_grains` window beside its existing
`run_outcome` tuning: its evalset is reference data read by the gate at review
time, so "never recalled in 30 days" measures the wrong thing for it -- and
retiring an evalset would remove the gate a code revision has to pass.

Two hand-written packs land as examples, both keyless and offline and both in
CI. `examples/grain-connector/` is #185's acceptance: a polling trigger whose
connector is a pinned wasm blob, with no host connector script anywhere, and
the `TRG-E012` refusal a host that pinned nothing gets.
`examples/blessed-tools/` is #179's: a pack binding the shipped `http.call`
blob with declared hosts, one permitted call (200 -- and the stub 401s anything
without the exact bearer token, so that is the proof the broker attached a
credential the tool never held), one call to an undeclared host refused by the
broker with `RUN-E022`, and `areev tool provenance` chaining the blob.

Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8
Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
@sathish-mg
sathish-mg force-pushed the feat/packs-grain-connectors-blessed-tools branch from 5b21b4d to f4ff575 Compare September 10, 2026 09:26
Two bugs the work in this branch surfaced, both in the same place: a piece of
governed code and the things that point at it.

**`areev tool provenance` reported no runs for a tool a run had just
executed.** `docs/run.md` said the command chains code "to the runs that
executed it", and it answered `runs_touching: 0`. The walk behind it is a
PROVENANCE walk — `derived_from` up, the reverse index down — and there is no
provenance edge to find: a journal's result grain supersedes its intent, and
neither supersedes the Definition. What connects a run to the code it ran is
§8.4's `spec_hash`, which the intent carries and nothing reads backwards.

`runs_touching` now also follows that edge for a Tool Definition
(`Areev::runs_executing`, useful on its own). It is a bounded scan rather than
an index read because `spec_hash` is a field and not a `related_to` link —
affordable for the same reason the runtime's definition-catalogue scan is, and
skipped entirely unless the target IS a Definition, so no other caller pays for
it. A conformance case pins it on both backends, since a scan is exactly the
kind of read that can differ when one backend's `recent` windows differently
from the other's. `examples/blessed-tools/` now asserts both runs — the refused
one included, because a request the broker turned down is still a run that
touched that code.

**`cold_grains` proposed retiring a Rule E1 gate.** An evalset a live Tool
Definition pins is read by the gate at review time, never through recall, so it
aged past the grace window and came back as a retire candidate — naming the one
grain that must not be retired, since removing it removes the gate a
`code_revision` has to pass. Recall counts measure whether a fact informs
*answers*; that fact's job is to judge *code*, so the analyzer was answering a
question nobody asked about it.

Facts pinned as `evalset_hash` by a live Definition are now excluded, and
deliberately only those. A general "any hash a live grain mentions" sweep would
also swallow the evidence a pending recommendation cites — and since this
analyzer's own findings cite the fact they flag, every cold finding would
suppress itself on the next run.

`examples/agents/sanctions-screening` drops the config widening it needed to
work around this and asserts the clean result instead, which is what makes the
fix provable end to end rather than only in a unit test.

Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8
Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
Five conflicts, all of them two features landing beside each other rather
than disagreeing:

- `areev-run/src/lib.rs` — `pin_from_definition` (#185) and `subgraph_run_id`
  (#187) are separate re-exports; both kept.
- both bindings — the trigger evaluator now builds a connector's code config
  (#185) AND an egress handle for the runs a firing starts (#201). Both lines
  belong, in that order. Main had independently added the same `path` field
  for the broker's blob door (#106), which is the same locator this branch
  wanted for a grain connector's `areev::blob_get`: one field, one doc naming
  both readers, rather than two fields with one name.
- `docs/run.md` — the binding spelling of a capability-tool run (#201) and the
  note that a trigger's connector is one of those too (#185). The first
  extends the snippet above it, so it goes first.
- `CHANGELOG.md` — separate entries in one list, main's ahead.

Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8
Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
Generated artifacts only: `scripts/repo_stats.py` over the merge. The coverage
input is unchanged — CI's `coverage` job measures the merged tree and its own
check is what would fail if the committed figure had drifted.

Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8
Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
Generated artifacts. The previous figure (81.8%) was measured before this
branch merged main, so it described neither tree — inside the gate's tolerance,
but a committed measurement should be a measurement of something. Every crate
is at or above its floor; `areev-mcp`, the tightest at 71.4% against a 71.0
floor, now measures 78.8% on main's own work.

Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8
Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
Both were mine, and both are the same shape of mistake — something that works
on the machine it was written on and cannot work on the machine CI runs.

`trigger_smoke`'s last step executed a pinned NATIVE blob, and the pack it
installs carries a `#!/bin/sh` one. Windows answered "%1 is not a valid Win32
application", which is correct: a native blob IS a program, so it is
platform-specific by construction and `docs/run.md` says to pin per platform.
The step is now `#[cfg(unix)]`. What stays cross-platform is the part that must
hold everywhere — the flag reaches the declaration, and an unpinned or
wrongly-pinned host refuses — and `grain_connector_tests` already gates its own
"and then it ran" the same way.

`examples/blessed-tools/run.sh` waited for its stub upstream with bash's
`/dev/tcp`, in a `#!/bin/sh` script. On macOS `/bin/sh` is bash and the probe
works; on Ubuntu it is dash, which has no such device, so the probe could never
succeed and the example failed after its ten-second budget. It now probes with
python3, which the example already requires because the stub is python3. Both
examples were re-run under dash — the shell CI actually uses — rather than
reasoned about.

Claude-Session: https://claude.ai/code/session_016YzyEfdWprezzATrZGNtg8
Signed-off-by: Sathish Kumar Palanisamy <sathish@mindgryd.com>
@sathish-mg
sathish-mg merged commit 127c24f into main Sep 10, 2026
38 of 39 checks passed
@sathish-mg
sathish-mg deleted the feat/packs-grain-connectors-blessed-tools branch September 10, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant